import React from 'react';

import { Pagination } from 'antd';

const defaultPage = {
  showSizeChanger: true,
  showQuickJumper: true,
  size: 'default',
  showTotal: (total) => `共 ${total} 条数据`,
};
const CommonPage = ({ pagination, style={}, handleChange, selectTotal }) => {
  const page = {
    ...defaultPage,
    ...pagination,
    size: 'small',
  };

  const handlePageChange = (page, size) => {
    handleChange(page, size);
  };

  return (
    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end', ...style }}>
      {selectTotal ? (
        <span style={{ marginRight: '20px' }}>
          当前页面已经选择<span className="common-color9">{selectTotal}</span>条
        </span>
      ) : (
        ''
      )}
      <Pagination {...page} onChange={handlePageChange} />
    </div>
  );
};

export default CommonPage;
